<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="pojo.*,service.*,base.*,java.sql.Timestamp;"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    if(session.getAttribute("name")!=null){
	 int dishesid=Integer.parseInt(request.getParameter("dishesid"));
     int userid=(Integer)session.getAttribute("id");
     DishesService ds = new DishesService();
     String dishesname = ds.getDishesDetail(dishesid).getName();
     int color=Integer.parseInt(request.getParameter("color"));
     int smell=Integer.parseInt(request.getParameter("smell"));
     int taste=Integer.parseInt(request.getParameter("taste"));
     String content=request.getParameter("content");

	ReviewService rs = new ReviewService();
	
	
	

	
	int r = rs.getnum(userid,dishesname);
	
	int s = rs.getreviewnum(userid,dishesid);
	
	if(r>s){
		rs.addDishesReview(userid,dishesid,color,smell,taste,content);
	
		out.print("添加成功！");
		response.setHeader("refresh","1;URL=../../website/dishesDetail.jsp?id="+dishesid) ;}
		
		else{
		
		out.print("您未预订过此菜或者是已评论过!!!!!!");
		response.setHeader("refresh","2;URL=../../website/dishesDetail.jsp?id="+dishesid);
		}
		
		
	}
	
	else response.sendRedirect("../../website/login.jsp");
%>
</body>
</html>
